package org.gpp.proj1.bone;

/**
 * Defines an animation keyframe interval
 * 
 * @author Paolo Victor, paolovictor@gmail.com
 */
public class KeyframeInterval {
	
	/**
	 * The starting frame
	 */
	private int begin;
	
	/**
	 * The end frame
	 */
	private int end;
	
	/**
	 * Default constructor
	 * 
	 * @param begin The initial keyframe. Must be a natural integer
	 * @param end The final keyframe. Must be a natural integer
	 */
	public KeyframeInterval( int begin, int end ) {
		
		assert begin >= 0 && end >= 0 : "Negative values aren't accepted";
		assert begin <= end : "Begin must be lesser or equal than end";
		
		this.begin = begin;
		this.end = end;
	}
	
	/**
	 * @return The initial keyframe
	 */
	public int getBegin() {
		return begin;
	}
	
	/**
	 * @return The final keyframe
	 */
	public int getEnd() {
		return end;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals( Object o ) {
		if( ! (o instanceof KeyframeInterval) ) {
			return false;
		}
		
		KeyframeInterval other = (KeyframeInterval) o;
		
		return begin == other.begin && end == other.end;
	}
}